﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace AWZhome.awzBoxes.TestApp
{
	/// <summary>
	/// Interaction logic for MainWindow.xaml
	/// </summary>
	public partial class MainWindow : Window
	{
		public MainWindow()
		{
			InitializeComponent();
			this.BoxWindowContainer.LayoutStorageProvider = new LayoutStorageTestProvider();
		}

		private void BoxItem_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			e.Cancel =
				(MessageBox.Show("Really close?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.No);
		}

		private void Button_Click(object sender, RoutedEventArgs e)
		{
			this.BoxWindowContainer.SaveLayout();
		}

		private void Button_Click_1(object sender, RoutedEventArgs e)
		{
			this.BoxWindowContainer.RestoreLayout();
			//((BoxArea) this.BoxWindowContainer.InnerAreaControl).BoxLines[0].Boxes[0].Items[0].Direction = BoxItemDockDirection.DockTop;

			//BoxLine newBoxLine = new BoxLine();
			//Box newBox = new Box();
			//BoxItem newBoxItem = new BoxItem()
			//{
			//    Name = "Window 3",
			//    Title = "Window 4 Title"
			//};
			//this.BoxWindowContainer.AddBoxItem(newBoxItem);

			//((BoxArea) this.BoxWindowContainer.InnerAreaControl).BoxLines.Add(newBoxLine);
			//newBoxLine.Boxes.Add(newBox);
			//newBox.Items.Add(newBoxItem);
		}

		private void BoxArea_ActiveBoxItemChanged(object sender, ActiveBoxItemChangedEventArgs e)
		{
			if (this.IsLoaded)
			{
				//MessageBox.Show("Old: " + (e.OldBoxItem != null ? e.OldBoxItem.Name : "null") + "\r\n"
				//    + "New: " + (e.NewBoxItem != null ? e.NewBoxItem.Name : "null") + "\r\n");
			}
		}

		private void Button_Click_2(object sender, RoutedEventArgs e)
		{
			//BoxArea bottomArea = this.BoxWindowContainer.BottomBoxArea;
			//if (this.BoxWindowContainer.BottomAutoHiddenBoxes.Count > 0)
			//{
			//    bottomArea.RestoreAutoHiddenBox(this.BoxWindowContainer.BottomAutoHiddenBoxes[0]);
			//}
			//else
			//{
			//    bottomArea.AutoHideBox(bottomArea.BoxLines[0].Boxes[1]);
			//}
		}

		private void Button_Click_3(object sender, RoutedEventArgs e)
		{
			foreach (var boxLine in this.BoxWindowContainer.RightBoxArea.BoxLines)
			{
				MessageBox.Show(this.BoxWindowContainer.RightBoxArea.GetRowHeight(this.BoxWindowContainer.RightBoxArea.BoxLines.IndexOf(boxLine), false).ToString());
			}

			//BoxArea rightArea = this.BoxWindowContainer.RightBoxArea;
			//if (rightArea.AutoHiddenBoxes.Count > 0)
			//{
			//    rightArea.RestoreAutoHiddenBox(rightArea.AutoHiddenBoxes[0]);
			//}
			//else
			//{
			//    rightArea.AutoHideBox(rightArea.BoxLines[1].Boxes[0]);
			//}
		}

		private void Button_Click_4(object sender, RoutedEventArgs e)
		{
			//BoxArea topArea = this.BoxWindowContainer.TopBoxArea;
			//if (this.BoxWindowContainer.TopAutoHiddenBoxes.Count > 0)
			//{
			//    topArea.RestoreAutoHiddenBox(this.BoxWindowContainer.TopAutoHiddenBoxes[0]);
			//}
			//else
			//{
			//    topArea.AutoHideBox(topArea.BoxLines[0].Boxes[1]);
			//}
		}

		private void Button_Click_5(object sender, RoutedEventArgs e)
		{
			//BoxArea leftArea = this.BoxWindowContainer.LeftBoxArea;
			//if (this.BoxWindowContainer.LeftAutoHiddenBoxes.Count > 0)
			//{
			//    leftArea.RestoreAutoHiddenBox(this.BoxWindowContainer.LeftAutoHiddenBoxes[0]);
			//}
			//else
			//{
			//    leftArea.AutoHideBox(leftArea.BoxLines[1].Boxes[0]);
			//}
		}
	}
}
